<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>


<div class="modal-dialog ms-modal-dialog" style="margin-top:50px;">
	<div class="modal-content">

		<div class="modal-header">
			<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
			<h4 class="modal-title">新增培训讲师</h4>
		</div>

		<form class="form-horizontal ms-form form-personal-info" method="POST" action="${ctx.host}/trainers" data-validate="true">

			<!--<input type="hidden" name="_method" value="PATCH" />-->

			<div class="modal-body">

				<div class="form-group  ms-form-group">
					<label class="control-label col-xs-3"><span class="text-red">*</span>讲师姓名：</label>
					<div class="col-xs-8">
						<input type="text" class="select2 form-control"  name="name" placeholder="讲师姓名" autocomplete="off" tabindex="1" />
						<!--<input type="text" class="form-control" name="name" id="userName" value="" placeholder="讲师姓名" data-validate="required" autocomplete="off" tabindex="1" />-->
					</div>
				</div>
				<div class="form-group  ms-form-group">
					<label class="control-label col-xs-3"><span class="text-red">*</span>邮箱：</label>
					<div class="col-xs-8">
						<input type="text" class="form-control" name="email"  placeholder="邮箱" data-validate="email" autocomplete="off" tabindex="1" />
					</div>
				</div>
				<div class="form-group  ms-form-group">
					<label class="control-label col-xs-3">是否认证：</label>
					<div class="col-xs-8 pull-left">
						<select class="select2 form-control" name="certified" data-validate="required">
							<option value="0">否</option>
							<option value="1">是</option>
						</select>
					</div>
				</div>
				<div class="form-group  ms-form-group">
					<label class="control-label col-xs-3">认证时间：</label>
					<div class="col-xs-8">
						<input type="text" class="form-control" name="certifiedDate" value="" tabindex="3" placeholder="请输入认证时间" autocomplete="off" />
					</div>
				</div>
				<div class="form-group  ms-form-group">
					<label class="control-label col-xs-3">讲师类型：</label>
					<div class="col-xs-8 pull-left">
						<select class="select2 form-control" name="trainerType">
							<option></option>
							<option>业务通识类</option>
							<option>管理类</option>
						</select>
					</div>
				</div>
				<div class="form-group  ms-form-group">
					<label class="control-label col-xs-3">讲师级别：</label>
					<div class="col-xs-8 pull-left">
						<select class="select2 form-control" name="trainerLevel">
							<option></option>
							<option>集团总部级</option>
							<option>区域级</option>
						</select>
					</div>
				</div>

			</div>
			<div class="modal-footer ms-modal-footer">
				<button type="submit" class="btn btn-shadow-success btn-shadow umu-btn">确定</button>
				<button type="button" class="btn btn-shadow-default btn-shadow umu-btn" data-dismiss="modal">取消</button>
			</div>

		</form>

	</div>
</div>
<script>
	$(document).ready(function(){
		
		$("input[name='name']").select2({
			placeholder: '请选择讲师',
			minimumResultsForSearch: 1,
			minimumInputLength: 2,
			allowClear: true,
			ajax: {
				type: 'GET',
				url: function(params) {
					return window.__CTX__.root + '/trainers/select?query=' +params
				},
				dataType: 'json',
				delay: 1500,
				results: function(response, page, i) {
					console.log(page)
					console.log(i)

					if(response.code == '0' || response.code == 0) {
						
						return {
							
							results: response.data.idmUser
						}
					} else {
						return null;
					}
				},
				cache: true
			}
			
		}).on("change", function(e){
			if(e.added){
				var email = e.added.email;
				/*$("input[name='userId']").select2("val", email);*/
				$("input[name='email']").val(email);
			}
			
		})
		
	})
</script>
